home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 10
/
010.d81
/
pps #23
< prev
next >
Wrap
Text File
|
2022-08-26
|
4KB
|
254 lines
PEEKs, POKEs, and SYSes -- Part 23
by Alan Gardner
======================================
Location: 55296-56295 Hex:$D800-DBFF
Official Label: none Type: RAM
Useful BASIC commands: PEEK, POKE
--------------------------------------
These 1000 locations are known
collectively as your color screen.
You are now 'looking' at all of these
locations. Every text character is
associated with a color. This is what
determines which colors you see on
screen.
The locations start in the upper-
left hand corner and proceed across
the screen. When you reach the right
side, you merely go back to the left
side, one line lower. It's just like
reading a book.
If you've read Part 22, you know
that we're working on left/right
scroll routine (actually only left
now). You'll also know that our
prior example can really mess up
the color on your text screen!
Here's a picture of our color
memory:
!{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}!{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}!{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}!{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}!{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}!
!55296!55297!55298!55299!.... !
! ! ! ! ! !
!{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}!{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}!{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}!{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}!{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}!
!55336!55337!55338!55339!.... !
! ! ! ! ! !
{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}
Have any ideas on what to do? (Hint:
remember Part 22 and the 8 steps.)
Did you guess moving what is in
location 55297 into location 55296,
then moving what is in location 55298
into location 55297, etc...
Again notice that if the location
is on the left side of the screen, we
move it off completely. But what if
it is on the far-right side? Well
we just fill those locations with the
current screen color.
Again we set a variable equal to the
base address of our color screen.
10 CS=55296: REM base address
Next, just like our example for the
text screen, we need to have two
loops. One loop is for going across
the screen, and the other loop is for
going down the screen.
20 FOR Y=0to24 : REM down screen
30 FOR X=0to38 : REM across screen
(Doesn't this all look VERY familiar?)
You might have noticed that we are
only going across for 39 locations
(0-38 is 39 characters). This is
because we want to store the screen
color in the right-most location on
each line.
Now we can use the same formula to
find out where we are on color screen:
COLOR=CS+40*Y+X
By using this formula, we can
calculate where we are on the screen.
40 COLR=CS+40*Y+X : REM where are we?
Now that we know where we are, we
can find out what is there and then
put it in the right place. Because
we are scrolling left, we want to
'look ahead' at the next location to
find out what to put in the current
location (make sense?).
Now for the rest of our program:
50 POKE COLR, PEEK(COLR+1)
60 NEXT X
70 POKE COLR+1,PEEK(53281)
80 NEXT Y
Line 50 is the main step in our
program. What it does is pick-up the
color in one location and put it into
the location directly to the left of
it. For example, it takes out what is
in location 55297 and puts what it
finds into locations 55296. This
produces our scroll left effect for
color. Line 70 is to put the screen
color into right-most locations.
That's all there is to scrolling the
color screen. Now, if we combine our
two routines, we have a working
scroll left routine. Let's take a
look at the finished product.
10 BA=1024:CS=55296
20 FORY=0to24
30 FORX=0to38
40 ADDR=BA+40*Y+X:COLR=CS+40*Y+X
50 POKE ADDR,PEEK(ADDR+1)
55 POKE COLR,PEEK(COLR+1)
60 NEXT X
70 POKE ADDR+1,32
75 POKE CORL+1,PEEK(53281)
80 NEXT Y
And that's it!! We now have a
scroll left routine. It's a bit(??)
slow, but it gets the job done.
Because it is so slow, I have
included a machine-language routine
of the same thing, with the added
feature of scrolling right. It is
saved under the name of SCROLL.L/R
on side 1 on this issue of LOADSTAR.
To use this routine in a program, here
is all you need:
10 IFX=0THENX=1:LOAD"SCROLL.L/R",8,1
20 :
30 REM SYS 49152 to scroll left
40 REM SYS 49155 to scroll right
50 :
60 REM Your program continues here!
Hope you can use this program and I
hope you have learned something. I
will leave learning how to scroll
right up to you, but I will tell you
that it is VERY similar to scrolling
left.
---------- end of article ------------